package concurrent;

/**
 * @author 刘正星
 * @version 1.0.0
 * @ClassName VolatileDemo.java
 * @Description TODO
 * @createTime 2021年04月11日 23:22:00
 */
public class VolatileDemo {

    public static volatile boolean flag = true;

    public static void main(String[] args) {
        new Thread(() -> {
            while (flag) {

            }
            System.out.println("===========End of Thread1==========");
        }).start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Trun flag off");
        flag = false;
    }

}
